<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="tb-image-map-source-settings tb-form-panel stroked" [formGroup]="imageMapSourceFormGroup">
  <div class="flex flex-row items-center justify-between">
    <div class="tb-form-panel-title">
      {{ 'widgets.maps.image.image-source' | translate }}
    </div>
    <tb-toggle-select formControlName="sourceType">
      <tb-toggle-option [value]="ImageSourceType.image">{{ 'widgets.maps.image.image-source-image' | translate }}</tb-toggle-option>
      <tb-toggle-option [value]="ImageSourceType.entityKey">{{ 'widgets.maps.image.image-source-entity-key' | translate }}</tb-toggle-option>
    </tb-toggle-select>
  </div>
  <tb-gallery-image-input *ngIf="ImageSourceType.image === imageMapSourceFormGroup.get('sourceType').value"
                          required
                          formControlName="url">
  </tb-gallery-image-input>
  <ng-container *ngIf="ImageSourceType.entityKey === imageMapSourceFormGroup.get('sourceType').value">
    <div class="tb-form-row column-xs">
      <div class="fixed-title-width" translate>widgets.maps.image.source-entity-alias</div>
      <tb-entity-alias-select
        class="flex-1"
        tbRequired
        inlineField
        [aliasController]="context.aliasController"
        formControlName="entityAliasId"
        [callbacks]="context.callbacks">
      </tb-entity-alias-select>
    </div>
    <div class="tb-form-row tb-standard-fields column-xs">
      <div class="fixed-title-width" translate>widgets.maps.image.image-url-key</div>
      <tb-data-key-input
        class="flex-1"
        required
        requiredText="widgets.maps.image.image-url-key-required"
        [datasourceType]="DatasourceType.entity"
        [entityAliasId]="imageMapSourceFormGroup.get('entityAliasId').value"
        [aliasController]="context.aliasController"
        [widgetType]="widgetType.latest"
        [dataKeyTypes]="[DataKeyType.attribute, DataKeyType.timeseries]"
        [callbacks]="context.callbacks"
        [generateKey]="context.generateDataKey"
        (keyEdit)="editKey()"
        formControlName="entityKey">
      </tb-data-key-input>
    </div>
  </ng-container>
</div>
